using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class CellSpaceUnityObject : UnityObject
{
    private void OnDrawGizmos()
    {
        CellSpace cellSpace = _linkedEntity.cellSpace.cellSpace;
        List<Cell> cells = cellSpace.GetCells();
        
        GUIStyle style = new GUIStyle();
        style.normal.textColor = Color.magenta;
        style.fontSize = 20;
        Gizmos.color = Color.magenta;
        for(int i = 0; i < cells.Count; i++)
        {
            Cell cell = cells[i];
            Vector3 min = cell.aabbBox.GetMin();
            Vector3 max = cell.aabbBox.GetMax();
            Vector3 center = (min + max) / 2;
            Vector3 size = max - min;
            Gizmos.DrawWireCube(center, size);
            Handles.Label(center, new GUIContent(i.ToString()), style);

            List<GameEntity> entities = cell.members;
            foreach (var e in entities)
            {
                if (!e.hasTransform)
                {
                    continue;
                }
                Handles.Label(e.transform.position, new GUIContent(i.ToString()), style);
            }
        }
    }
}